package org.niko.ds.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * The domain object to store the database field information.
 * @author dzhang
 */
@Entity
@Table( name = "ds_columns" )
public class DsColumn {
	
	@Id
	@Column( name = "ID" )
	@GeneratedValue( strategy = GenerationType.AUTO )
	private long id;
	
	@Column( name = "NAME" )
	private String name;
	
	@Column( name = "CTYPE" )
	private String type;
	
	@Column( name = "SIZE" )
	private int size;
	
	@Column( name = "NOTNULL" )
	private boolean isNullable;
	
	@Column( name = "CKEY" )
	private String key; // PK, FK

	@ManyToOne( fetch = FetchType.EAGER )
	@JoinColumn(name="TID")
	private DsTable table;
	
	public DsTable getTable() {
		return table;
	}

	public void setTable(DsTable table) {
		this.table = table;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public boolean isNullable() {
		return isNullable;
	}

	public void setNullable(boolean isNullable) {
		this.isNullable = isNullable;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
}
